export interface ActionResultTemplateInterface {
  code: number;
  message: string;
  data: any;
}
class ActionResultTemplate implements ActionResultTemplateInterface {
  code: number;
  message: string;
  data: any;
  constructor(code: number, message: string, data: any) {
    /**
     * 操作结果代码 0 - 成功 1 - 失败 2 - 无权限 3 - 未登录 4 - 超时
     */
    this.code = code;
    this.message = message;
    this.data = data;
  }
}
const ActionResult = {
  success({ message, data }: { message: string; data: any }) {
    return new ActionResultTemplate(0, message, data);
  },
  fail({ message, data }: { message: string; data: any }) {
    return new ActionResultTemplate(1, message, data);
  },
  noauth({ message, data }: { message: string; data: any }) {
    return new ActionResultTemplate(2, message, data);
  },
  nologin({ message, data }: { message: string; data: any }) {
    return new ActionResultTemplate(3, message, data);
  },
  timeout({ message, data }: { message: string; data: any }) {
    return new ActionResultTemplate(4, message, data);
  },
  other({ message, data, code }: { message: string; data: any; code: number }) {
    return new ActionResultTemplate(code, message, data);
  },
};
export default ActionResult;
